#coding=utf-8
#仓库frame
#time:20170912


import wx
import wx.dataview as dv
from DvList import DataViewIndexListModel

#库存面板
class RepertoryFrame(wx.Frame):
	def __init__(self, parent,id=-1,pos=wx.DefaultPosition, size=(-1, -1)):
		wx.Frame.__init__(self, parent, -1, 'self.title',style=wx.MINIMIZE_BOX|wx.SIMPLE_BORDER|wx.SIMPLE_BORDER)
		self.SetBackgroundColour("#ffffff")
		self.parent = parent
		self.sizer = wx.BoxSizer(wx.VERTICAL)

		self.OneB = wx.BoxSizer(wx.HORIZONTAL)


		self.OnShowView()

		

		self.SetSizer(self.sizer)
		self.Fit()


	def OnShowView(self):

		OneP = wx.Panel(self,-1)
		wx.StaticText(OneP,-1,u'商品库存表',pos=(10,13)).SetFont(wx.Font(16,wx.DEFAULT, wx.NORMAL, wx.BOLD))
		self.OutKucun = wx.Button(OneP,-1,u'导出系统库存',pos=(150,10))
		self.pandian = wx.Button(OneP,-1,u'盘点',pos=(250,10))
		self.OneB.Add(OneP,1,wx.EXPAND)
		TwoP = wx.Panel(self,-1)
		wx.StaticText(TwoP,-1,u'仓库：',pos=(10,13))
		self.cangku = wx.TextCtrl(TwoP,-1,pos=(50,10),size=(100,25))
		wx.StaticText(TwoP,-1,u'商品：',pos=(160,13))
		self.shangpin = wx.TextCtrl(TwoP,-1,pos=(210,10),size=(200,25))
		self.shangpin.SetLabelMarkup(u'商品名称或编码')
		self.chaxun = wx.Button(TwoP,-1,u'查询',pos=(430,10))
		wx.StaticText(TwoP,-1,u'',pos=(530,13),size=(10,35))

		self.OneB.Add(TwoP,0,wx.EXPAND)
		self.sizer.Add(self.OneB,0,wx.EXPAND)

		self.dvc = dv.DataViewCtrl(self,
			style=dv.DV_ROW_LINES   #交替色
			| dv.DV_VERT_RULES #显示列之间的分隔线。
			| dv.DV_SINGLE   #多选模式
			,size=(-1,350))

		data = []
		model = None
		if model is None:
			self.model = DataViewIndexListModel(data, '')
		else:
			self.model = model

		self.dvc.AssociateModel(self.model)

		self.dvc.AppendTextColumn(u"商品编码",1,width=200,  mode=dv.DATAVIEW_CELL_EDITABLE,flags=1)
		self.dvc.AppendTextColumn(u"商品名称",2,width=350,  mode=dv.DATAVIEW_CELL_EDITABLE)
		self.dvc.AppendTextColumn(u"单位",3,width=200,  mode=dv.DATAVIEW_CELL_EDITABLE)
		self.dvc.AppendTextColumn(u"库存数量",4,width=100,   mode=dv.DATAVIEW_CELL_EDITABLE)
		c0 = self.dvc.PrependTextColumn(u"行号",0)
		self.dvc.SetRowHeight(30)

		for i in range(30):
			self.model.AddRow([i+1, '', '', '', ''])

		c0.Alignment = wx.ALIGN_CENTER
		
		#设置可以排序
		for c in self.dvc.Columns:
			c.Sortable = True
			c.Reorderable = True

		self.sizer.Add(self.dvc,1,flag=wx.EXPAND)



#